package lsl.leetCode.year2023.test0205;

import java.util.HashSet;

/**
 * 剑指 Offer 03. 数组中重复的数字
 * @author Zed
 * @description
 * @date 2023/2/5 19:06
 */
//使用HashSet
public class offer03 {
    public static void main(String[] args) {

    }
    public static int findRepeatNumber(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if (!set.add(nums[i])) {
                return nums[i];
            }
            set.add(nums[i]);
        }
        return -1;
    }
}
